from typing import List
from sklearn.feature_extraction.text import TfidfVectorizer


class Encoder:
    def __init__(self, model_name: str = "tfidf"):
        self.vectorizer = TfidfVectorizer()


    def fit(self, texts: List[str]):
        self.vectorizer.fit(texts)

    def encode(self, texts: List[str]) -> List[List[float]]:
        tfidf_matrix = self.vectorizer.transform(texts).toarray()
        return [list(row) for row in tfidf_matrix]
